package com.jueban.Dto;


import com.jueban.model.ApplyInfo;
import com.jueban.util.Enum.ApplyOfIPType;
import lombok.Data;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.List;

@Data
public class ApplyInfoDto {

    @NotBlank
    private String applyIPName; //申请专利名

    private String department;  //部门 自动生成

    @NotBlank(message = "第一发明人不能空")
    private String firstInventor;   //第一发明人

    @NotBlank(message = "电话号码不能为空")
    private String phone;   //电话

    @NotNull(message = "成员不能为空")
    private String member;    //成员

    @Pattern(regexp = "发明|实用新型|外观|著作权", message = "没有此申请类型")
    @NotBlank(message = "申请类型不能为空")
    private String applyType;    //申请类型

    private String inventorType;    //发明人类型

    @NotNull(message = "专利范围不能为空")
    private String patentScope; //专利范围

    @NotNull(message = "是否依托项目不能为空")
    private Boolean isRelying;  //是否依托项目

    private String projectName; //依托项目名称

    private String projectId;   //依托项目编号

    @NotNull(message = "项目承担经费不能为空")
    private Double fundsUndertake;  //项目经费承担

    @NotNull(message = "学院资助不能为空")
    private Double academySubsidize;    //学院资助

    @Pattern(regexp = "国家级|省部级|市厅级|院级|横向协作|自筹", message = "没有此项目来源")
    @NotBlank(message = "项目来源不能为空")
    private String projectSource;   //项目来源


    public void transferData(ApplyInfo applyInfo) {
        BeanUtils.copyProperties(this, applyInfo);
        applyInfo.setApplyType(ApplyOfIPType.valueOf(applyType));
    }
}
